<!DOCTYPE html>
<html class="loginHtml">
<head>
    <meta charset="utf-8">
    <title>登录--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="resources/favicon.ico">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="resources/css/public.css" media="all"/>
    <style>
        .layui-layer.layui-layer-loading .layui-layer-content {
            width: 150px;
            height: 112px;
            background: url("/resources/images/login_bg.jpg") no-repeat;
        }
    </style>
</head>
<body class="loginBody">
<form class="layui-form" style="height: 480px">
    <div class="login_face"><img src="resources/images/face.jpg" class="userAvatar"></div>
    <div class="layui-form-item input-item  ">
        <label for="telephone">名字</label>
        <input type="text" placeholder="请输入电话" autocomplete="off" id="mName" name="mName" class="layui-input"
               lay-verify="required">
    </div>
    <div class="layui-form-item input-item  ">
        <label for="telephone">手机号</label>
        <input type="text" placeholder="请输入电话" autocomplete="off" id="telephone" name="telephone" class="layui-input"
               lay-verify="required">
        <button type="button" id="fs" name="fs" class="layui-btn layui-block"><span id="zz">发送验证码</span></button>
    </div>
    <div class="layui-form-item input-item">
        <label for="yzm">验证码</label>
        <input type="text" placeholder="请输入验证密码" autocomplete="off" id="yzm" name="yzm" class="layui-input"
               lay-verify="required">
    </div>
    <div class="layui-form-item input-item">
        <label for="password">设置密码</label>
        <input type="password" placeholder="请输入新密码" autocomplete="off" id="password" name="password" class="layui-input"
               lay-verify="required">
    </div>
    <div class="layui-form-item input-item">
        <label for="password">确认密码</label>
        <input type="password" placeholder="请输入新密码" autocomplete="off" id="password1" name="password1"
               class="layui-input" lay-verify="required">
    </div>

    <div class="layui-form-item">
        <button class="layui-btn layui-block" lay-filter="zc" lay-submit>立即注册</button>
        <a href="login.html"><span class="btn-small">返回登陆界面</span></a>&nbsp;
    </div>
</form>

<script type="text/javascript" src="resources/layui/layui.js"></script>
<script type="text/javascript" src="resources/js/cache.js"></script>
<script>
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate;

        $(".loginBody .seraph").click(function () {
            layer.msg("这只是做个样式，至于功能，你见过哪个后台能这样登录的？还是老老实实的找管理员去注册吧", {
                time: 5000
            });
        })
        var countdown = 10;

        function setTime() {
            if (countdown == 0) {
                $("#zz").html("发送验证码")
                $("#fs").css("color", "white");
                $("#fs").attr('disabled', false)
                countdown = 10;
            } else {
                $("#fs").attr('disabled', true)
                $("#fs").css("color", "red");
                $("#zz").html("重新发送(" + countdown + ")")
                countdown = countdown - 1;
                setTimeout(function () {
                    setTime()
                }, 1000)
            }
        }

        //生成验证码
        $("#fs").click(function () {
            var z = $("#telephone").val()
            if (z == '') {
                layer.msg("请输入手机号")
            } else {
                $.ajax({
                    url: "forgett.do",
                    data: {telephone: z},
                    type: "GET",
                    dataType: "json",
                    success: function (res) {
                        console.log(res)
                        if (res.code == 200) {
                            $("#yzm").mouseout(function () {
                                var z = $("#telephone").val()
                                $.ajax({
                                    url: "inputCode.do",
                                    type: "get",
                                    data: {telephone: z},
                                    success: function (res) {
                                        code = res.msg;
                                        var inputCode = $("#yzm").val();
                                        console.log(inputCode)
                                        var x = $("#password").val();
                                        var y = $("#password1").val();
                                        if (inputCode == "") { //若输入的验证码长度为0
                                            layer.msg("请输入验证码");
                                            return false;
                                        } else if (inputCode != code) { //若输入的验证码与产生的验证码不一致时
                                            console.log("+++++++++++++++++++++++++++++++++++++++++++++++++++++")
                                            layer.msg("验证码错误");
                                            return false;
                                        }
                                    }
                                })
                            })
                        }
                    }
                })
            }
        })

        var code;
        //登录按钮
        form.on("submit(zc)", function (data) {

            console.log("************************************************************")
            var m_phoneNum = data.field.telephone;
            var m_password = data.field.password;
            var mName=data.field.mName;
            // $.ajax({
            //     url: "addpuser.do",
            //     type: "POST",
            //     data: {m_phoneNum:m_phoneNum,m_password:m_password},
            //     dataType: "json",
            //     success: function (res) {
            //         console.log("************************************************************")
            //         if (res.code == 200) {
            //             layer.msg("注册成功");
            //             window.location = "login1111111.do"
            //             return false;
            //         } else {
            //             layer.msg("注册失败");
            //         }
            //     }
            // });
            $.post("/addpuser.do", {m_phoneNum:m_phoneNum,m_password:m_password,mName:mName}, function (res) {
                if (res.code == 200) {
                    setTimeout(function () {
                        layer.msg("注册成功");
                        window.location = "login1111111.do"
                        return false;
                    }, 2000)
                } else {
                    layer.msg("注册失败");
                    location.reload();
                }
            }, "json")
            return false;
        })
        //表单输入效果
        $(".loginBody .input-item").click(function (e) {
            e.stopPropagation();
            $(this).addClass("layui-input-focus").find(".layui-input").focus();
        })
        $(".loginBody .layui-form-item .layui-input").focus(function () {
            $(this).parent().addClass("layui-input-focus");
        })
        $(".loginBody .layui-form-item .layui-input").blur(function () {
            $(this).parent().removeClass("layui-input-focus");
            if ($(this).val() != '') {
                $(this).parent().addClass("layui-input-active");
            } else {
                $(this).parent().removeClass("layui-input-active");
            }
        })
    })

</script>

</body>
</html>